import { addressList } from '@/api/address'
const getters = {
  selectAddress (state) {
    return state.addressList[0] || {}
  },
  longAddress (state, getters) {
    const region = getters.selectAddress.region
    return region.province + region.city + region.region + getters.selectAddress.detail
  }
}
const mutations = {
  setAddress (state, addressList) {
    state.addressList = addressList
  }
}
const actions = {
  async getAddressList (context) {
    const { data: { list } } = await addressList()
    context.commit('setAddress', list)
    console.log(list)
  }
}
const state = {
  addressList: []
}

export default {
  namespaced: true,
  getters,
  mutations,
  actions,
  state
}
